﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;

namespace Moonwish.SchoolDorms.BusinessComponent.Utility
{
    public class WebConfig
    {
        private static string _connString;

        public static string ConnectionString
        {
            get { 
                if (string.IsNullOrEmpty(_connString))
                {
                    var connStr = System.Configuration.ConfigurationManager.ConnectionStrings["DormsDb"];
                    if (connStr != null)
                    {
                        if (HostingEnvironment.ApplicationVirtualPath != null)
                            _connString = string.Format(connStr.ConnectionString, HostingEnvironment.MapPath(@"~")).Replace("宿舍管理系统\\" + HostingEnvironment.ApplicationVirtualPath.Trim('/'), @"公共\Moonwish.Main.Silverlight.Web\ClientBin\");
                    }
                }
                return _connString;
            }
        }
    }
}
